const mongoose = require('mongoose')
const md5 = require('../util/md5')

// 创建用户数据模型
module.exports = new mongoose.Schema({
  username: {
    type: String,
    required: true
  },
  email: {
    type: String,
    required: true
  },
  password: {
    type: String,
    required: true,
    set: value => md5(value), //对密码进行加密处理
    select: false
  },
  bio: {
    type: String,
    default: null
  },
  image: {
    type: String, //头像保存地址
    default: null
  },
  ...require('./base-model')
})
